package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class Delete {
    public static void main(String[] args) throws SQLException {
            String url = "jdbc:mysql://127.0.0.1:3306/linyujie?useUnicode=true&amp;characterEncoding=utf-8";
            String username = "root";
            String password = "123456";
            Connection con = null;
            PreparedStatement p = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection(url,username,password);
                String sql = "delete from user where id=?";
                p = con.prepareStatement(sql);
                p.setInt(1,1);
                int b = p.executeUpdate();
                if(b == 1){
                    System.out.println("成功");
                }else{
                    System.out.println("失败");
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            con.close();
            p.close();
        }
    }

